package com.example.oasystem.service.impl;

import com.example.oasystem.dao.process.AoaProcessDaoOfSun;
import com.example.oasystem.entity.notice.AoaNoticeListOfSun;
import com.example.oasystem.entity.position.AoaPosition;
import com.example.oasystem.entity.process.AoaProcessOfSun;
import com.example.oasystem.entity.process.AoaReviewedOfSun;
import com.example.oasystem.entity.status.AoaStatusList;
import com.example.oasystem.entity.user.AoaUser;
import com.example.oasystem.service.AoaProcessServiceOfSun;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class AoaProcessServiceImplOfSun implements AoaProcessServiceOfSun{

    @Autowired
    private AoaProcessDaoOfSun aoaProcessDaoOfSun;

    @Override
    public PageInfo<AoaProcessOfSun> selectProcessAndTypeAndStatus(int pageNum, int pageSize, String baseKey,String userName) {
        PageHelper.startPage(pageNum,pageSize);
        List<AoaProcessOfSun> aoaProcessOfSuns = aoaProcessDaoOfSun.selectProcessAndTypeAndStatus(userName, baseKey);
        PageInfo<AoaProcessOfSun> pageInfo = new PageInfo<>(aoaProcessOfSuns);
        return pageInfo;
    }


    @Override
    public AoaProcessOfSun selectProcess(long id) {
        return aoaProcessDaoOfSun.selectProcess(id);
    }

    @Override
    public AoaProcessOfSun selectUserProcess(long id) {
        return aoaProcessDaoOfSun.selectUserProcess(id);
    }

    @Override
    public AoaPosition selectposition(long positionId) {
        return aoaProcessDaoOfSun.selectposition(positionId);
    }


    @Override
    public AoaStatusList selectStatus(long statusId) {
        return aoaProcessDaoOfSun.selectStatus(statusId);
    }

    @Override
    public void updateStatus(long statusId, long id) {
        aoaProcessDaoOfSun.updateStatus(statusId,id);
    }

    @Override
    public AoaProcessOfSun selectOneProcess(String userName) {
        return null;
    }

    @Transactional
    @Override
    public void insertProcessUser(long proId, long status,long statusId,long userId) {
        aoaProcessDaoOfSun.updateReviewedStatus(proId,statusId,userId);
        aoaProcessDaoOfSun.insertProcessUser(proId,status);
    }


    @Override
    public void addUserReviewed(long statusId, long proId,long userId) {
        aoaProcessDaoOfSun.addUserReviewed(statusId,proId,userId);
    }

    @Override
    public void updateUserName(long proId, String userName) {
        aoaProcessDaoOfSun.updateUserName(proId, userName);
    }

    @Override
    public List<AoaReviewedOfSun> reviewedSize(long proId,long statusId) {
        return aoaProcessDaoOfSun.reviewedSize(proId,statusId);
    }

    @Override
    public void updateUserReviewed(String advice, String time, long statusId, long proId, long userId) {
        aoaProcessDaoOfSun.updateUserReviewed(advice, time, statusId, proId, userId);
    }

    @Override
    public List<AoaReviewedOfSun> processReviewedAll(long proId) {
        return aoaProcessDaoOfSun.processReviewedAll(proId);
    }

    @Override
    public void updateResign(long proId,  String advice, int num) {
        aoaProcessDaoOfSun.updateResign(proId,advice,num);
    }

    @Override
    public void updateBursement(long proId,  String advice, int num) {
        aoaProcessDaoOfSun.updateBursement(proId,advice,num);
    }

    @Override
    public void updateOvertime(long proId,  String advice, int num) {
        aoaProcessDaoOfSun.updateOvertime(proId,advice,num);
    }

    @Override
    public void updateRegular(long proId, String advice, int num) {
        aoaProcessDaoOfSun.updateRegular(proId,advice,num);
    }

    @Override
    public void updateEvenction(long proId,  String advice, int num) {
        aoaProcessDaoOfSun.updateEvenction(proId,advice,num);
    }

    @Override
    public void updateHoliday(long proId, String advice, int num) {
        aoaProcessDaoOfSun.updateHoliday(proId,advice,num);
    }


//    @Override
//    public AoaProcessOfSun selectAll(String name, long processId) {
//        return aoaProcessDaoOfSun.selectAll(name, processId);
//    }
}
